package com.mapper;

import com.pojo.Tags;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TagsMapper {

    @Insert("INSERT INTO tags(name, created_at) VALUES(#{name}, #{createdAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Tags tag);

    @Update("UPDATE tags SET name=#{name} WHERE id=#{id}")
    int update(Tags tag);

    @Delete("DELETE FROM tags WHERE id=#{id}")
    int delete(Integer id);

    @Select("SELECT * FROM tags WHERE id=#{id}")
    Tags selectById(Integer id);

    @Select("SELECT * FROM tags")
    List<Tags> selectAll();
}